export default {
	// 截取视频帧
	getVideoCanvas(res) {
		let canvas = res[0].node;
		this.canvas = canvas
		canvas.width = this.videoWidth * this.pixelRatio
		canvas.height = this.videoHeight * this.pixelRatio
		this.canvasHeight = this.videoHeight
		this.canvasWidth = this.videoWidth
		this.ctx = canvas.getContext("2d")
		const duration = Math.floor(Math.random() * this.duration);
		this.video.seek(duration) // 指定播放位置
		this.timer = setTimeout(() => {
			this.ctx.drawImage(this.video, 0, 0, this.videoWidth * this.pixelRatio, this
				.videoHeight * this.pixelRatio)
			this.imageSrc = this.canvas.toDataURL('image/png')
			console.log(this.imageSrc)
			clearTimeout(this.timer)
		});
	},
	// 下载图片url等信息
	downloadFileVideo(url) {
		return new Promise((r, j) => {
			uni.downloadFile({
				url: url,
				success: r,
				fail: j
			})
		})
	}
}